local wjsl_zhujia = fk.CreateSkill {
  name = "wjsl_zhujia",
}


wjsl_zhujia:addEffect("active", {
  -- anim_type = "support",
  min_card_num = 1,
  max_card_num = 2,
  can_use = function(self, player)
    return player:hasSkill(wjsl_zhujia.name) and player.phase == Player.Play and
    player:usedSkillTimes(wjsl_zhujia.name, Player.HistoryTurn) < math.ceil(player:getMark("curlayerphase") / 10) * 2 + 1
  end,
  card_filter = function(self, player, to_select, selected)
    local card = Fk:getCardById(to_select)
    if #selected == 0 then
      if card.type == Card.TypeEquip or card.name == "jink" then
        return true
      end
    elseif #selected == 1 then
      if player.shield >= 5 then
        return
      end
      if Fk:getCardById(selected[1]).name == "jink" then
        return card.name == "jink"
      end
      if Fk:getCardById(selected[1]).type == Card.TypeEquip then
        return card.type == Card.TypeEquip
      end
    elseif #selected == 2 then
      return false
    end
  end,
  target_filter = function(self, player, to_select, selected)
    return false
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    if #effect.cards == 1 then
      room:recastCard(effect.cards, player, wjsl_zhujia.name)
    else
      room:throwCard(effect.cards, wjsl_zhujia.name, player, player)
      room:changeShield(player, 1)
      room:addPlayerMark(player, "wjsl_zhujia_shield", 1)
    end
  end,
})


return wjsl_zhujia
